<?php

require_once 'conexao.php';

echo"
    <script language='javascript'>

    </script>
";

if ($_POST['chamada'] == 'frota') {
    $query = "SELECT placa, dt_entrada, hr_entrada FROM frota WHERE dt_saida = '0000-00-00'";
    $result = mysql_query($query);
    $cont = 0;

    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

        $data = explode("-", $row['dt_entrada']);
        echo "<table>";
        if ($cont % 2 == 0) {
            echo "<tr style='background: #D3D3D3'><div>";
        } else {
            echo "<tr>";
        }
        echo "<td>";
        echo '<img src="./imagens/garagem_icone.png"></img>';
        echo "</td>";
        echo "<td style='text-align:center; width:74px; padding-left:13px'>";
        echo $row['placa'];
        echo "</td>";
        echo "<td style='width:65px; padding-left:10px'>";
        echo $data[2] . '/' . $data[1] . '/' . $data[0];
        echo "</td>";
        echo "<td style='padding-left:10px'>";
        echo substr($row['hr_entrada'], 0, 5);
        echo "</td>";
        echo "</tr></div>";
        echo "</table>";
        $cont++;
    }
}
if ($_POST['chamada'] == 'visitante') {

    $query = "SELECT visitante.dt_entrada, visitante.hr_entrada, visitante.permissao, visitante.cracha, cadastro.nome, cadastro.empresa FROM visitante, cadastro WHERE visitante.dt_saida = '0000-00-00' and visitante.rg = cadastro.rg";
    $resultado = mysql_query($query);
    $cont = 0;

    while ($row = mysql_fetch_array($resultado, MYSQL_BOTH)) {

        $data = explode("-", $row['dt_entrada']);
        echo "<table>";
        if ($cont % 2 == 0) {
            echo "<tr style='background: #D3D3D3'>";
        } else {
            echo "<tr>";
        }
        echo "<td>";
        echo '<img src="./imagens/visitante_icone.png"></img>';
        echo '</td>';
        echo "<td style='width:150px; padding-left:15px'>";
        echo $row['nome'];
        echo "</td>";
        echo "<td style='width:190px'>";
        echo $row['empresa'];
        echo "</td>";
        echo "<td style='width:80px'>";
        echo $data[2] . '/' . $data[1] . '/' . $data[0];
        echo "</td>";
        echo "<td>";
        echo substr($row['hr_entrada'], 0, 5);
        echo "</td>";
        echo "</tr>";
        echo "</table>";
        $cont++;
    }
}

if ($_POST['chamada'] == 'prestador') {
    $query = "SELECT placa, dt_entrada, hr_entrada FROM prestador WHERE dt_saida = '0000-00-00'";
    $result = mysql_query($query);
    $cont = 0;

    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

        $data = explode("-", $row['dt_entrada']);
        echo "<table>";
        if ($cont % 2 == 0) {
            echo "<tr style='background: #D3D3D3'>";
        } else {
            echo "<tr>";
        }
        echo "<td>";
        echo '<img src="./imagens/prestador_icone.png"></img>';
        echo "</td>";
        echo "<td style='text-align:center; width:74px; padding-left:13px'>";
        echo $row['placa'];
        echo "</td>";
        echo "<td style='width:65px; padding-left:10px'>";
        echo $data[2] . '/' . $data[1] . '/' . $data[0];
        echo "</td>";
        echo "<td style='padding-left:10px'>";
        echo substr($row['hr_entrada'], 0, 5);
        echo "</td>";
        echo "</tr>";
        echo "</table>";
        $cont++;
    }
}
?>

